<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('修改岗位')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-job-edit" class="form-horizontal" AUTOCOMPLETE="OFF">
        <input name="id" id="id" type="hidden" th:value="${job.id}"/>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">岗位代码：</label>
                    <div class="col-sm-8">
                        <input name="Jobcode" id="Jobcode" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')"
                               class="form-control" type="text" th:value="${job.Jobcode}"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>岗位名称：</label>
                    <div class="col-sm-8">
                        <input name="Title" id="Title" class="form-control" type="text" th:value="${job.Title}" required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>岗位简称：</label>
                    <div class="col-sm-8">
                        <input name="JobAbbr" id="JobAbbr" class="form-control" type="text" th:value="${job.JobAbbr}"  required/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>岗位级别：</label>
                    <div class="col-sm-8">
                        <select name="JobGrade" id="JobGrade" class="form-control m-b"
                                th:with="type=${@dict.getType('oCD_jobgrade')}" required>
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:selected="${job.JobGrade+'' == dict.dictValue}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>岗位类型：</label>
                    <div class="col-sm-8">
                        <select name="JobType" id="JobType" class="form-control m-b"
                                th:with="type=${@dict.getType('oCD_JobType')}" required>
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:selected="${job.JobType+'' == dict.dictValue}"
                                    th:value="${dict.dictValue}"></option>
                        </select></div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">所属公司：</label>
                    <div class="col-sm-8">
                        <input name="compTitle" id="compTitle" class="form-control" type="text" th:value="${job.compTitle}" disabled="disabled"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">所属部门：</label>
                    <div class="col-sm-8">
                        <input name="DepIdTitle" id="DepIdTitle" class="form-control" type="text" th:value="${job.DepIdTitle}" disabled="disabled"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">上级岗位：</label>
                    <div class="col-sm-8">
                        <select id="AdminID" name="AdminID" class="form-control">
                            <option value="">请选择</option>
                            <option th:each="dep:${dep}" th:value="${dep.jobId }"  th:selected="${job.AdminID == dep.jobId}"
                                    th:text="${dep.title }"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">编制人数：</label>
                    <div class="col-sm-8">
                        <input name="Jobnum" id="Jobnum" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" class="form-control" type="text"  th:value="${job.Jobnum}" required/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">岗位说明：</label>
                    <div class="col-sm-8">
                        <input name="jobText" id="jobText" class="form-control" type="text" th:value="${job.jobText}"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>变更日期：</label>
                    <div class="col-sm-8">
                        <input name="effectdate" id="effectdate" class="form-control laydate-demo-1" type="text" th:value="${job.effectdate}" required/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">备注：</label>
                    <div class="col-sm-8">
                        <input name="Remark" id="Remark" class="form-control" type="text" th:value="${job.Remark}"/>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-suggest-js"/>
<th:block th:include="include :: bootstrap-typeahead-js"/>

<script>
    var prefix = ctx + "job/admin";
    $(function () {

        $(".datetimepicker-demo-1").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-1',
                type: 'date'
            });
        });



    });

    function submitHandler() {

        //下拉校验
        var id = $("#id").val();
        var JobGrade = $("#JobGrade").val();
        var JobType = $("#JobType").val();




        if (JobGrade == "" || JobGrade == null) {
            $.modal.alertWarning("请选择岗位级别!");
            return;
        } else if (JobType == "" || JobType == null) {
            $.modal.alertWarning("请选择岗位类型!");
            return;
        }

        if ($.validate.form()) {
            var data = $("#form-job-edit").serializeArray();

            var Jobcode = $("#Jobcode").val();
            var Title = $("#Title").val();
            var JobAbbr = $("#JobAbbr").val();
            var AdminID = $("#AdminID").val();
            var Jobnum = $("#Jobnum").val();
            var jobText = $("#jobText").val();
            var effectdate = $("#effectdate").val();
            var Remark = $("#Remark").val();

            data.push({"id": "Jobcode", "value": Jobcode});
            data.push({"id": "Title", "value": Title});
            data.push({"id": "JobAbbr", "value": JobAbbr});
            data.push({"id": "AdminID", "value": AdminID});
            data.push({"id": "Jobnum", "value": Jobnum});
            data.push({"id": "jobText", "value": jobText});
            data.push({"id": "effectdate", "value": effectdate});
            data.push({"id": "Remark", "value": Remark});
            $.operate.save(prefix + "/editEdit", data);
        }
    }


    $.get(ctx + "depart/admin/getEmpRow", function (data) {
        console.log(data);
        $("#directorName").typeahead({
            source: data.value
        });
        $("#director2Name").typeahead({
            source: data.value
        });
    }, 'json');

    $.get(ctx + "depart/admin/getDepRow", function (data) {
        console.log(data);
        $("#funcationName").typeahead({
            source: data.value
        });
    }, 'json');
</script>
</body>
</html>